<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">


      <el-form-item label="用户手机号" prop="buiId">
        <el-input
          v-model="queryParams.phone"
          placeholder="请输入用户手机号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="用户姓名" prop="userName">
        <el-input
          v-model="queryParams.userName"
          placeholder="请输入用户姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="支付宝账号" prop="aliPhone">
        <el-input
          v-model="queryParams.aliPhone"
          placeholder="请输入支付宝账号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="支付宝真实姓名" prop="aliUserName">
        <el-input
          v-model="queryParams.aliUserName"
          placeholder="请输入支付宝真实姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>


      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>



    <el-table v-loading="loading" :data="logsList" >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="用户编号" align="center" prop="userId" />
      <el-table-column label="用户手机号" align="center" prop="userPhone" />
      <el-table-column label="用户昵称" align="center" prop="nickName" />
      <el-table-column label="支付宝账号" align="center" prop="aliPhone" />
      <el-table-column label="支付宝姓名" align="center" prop="aliName" />
      <el-table-column label="今日释放量" align="center" prop="toDayOpen" />
      <el-table-column label="今日获取量" align="center" prop="toDayGet" />
      <el-table-column label="释放总量" align="center" prop="openCount" />
      <el-table-column label="获取总量" align="center" prop="getCount" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['admin:logs:edit']"
          >详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改业务日志对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-table v-loading="loading" :data="userLogsInfosList" >
        <el-table-column label="用户编号" align="center" prop="id" />

        <el-table-column label="手机号" align="center" prop="phone" />
        <el-table-column label="用户姓名" align="center" prop="userName" />
        <el-table-column label="数量" align="center" prop="formInfo" />
        <el-table-column label="类型" align="center" prop="isType" />
        <el-table-column label="说明" align="center" prop="jsonTxt" />
        <el-table-column label="创建时间" align="center" prop="createTime" />
      </el-table>

      <pagination
        v-show="infoTotal>0"
        :total="infoTotal"
        :page.sync="infoQueryParams.pageNum"
        :limit.sync="infoQueryParams.pageSize"
        @pagination="getInfoList"
      />
    </el-dialog>
  </div>
</template>

<script>
import {listDisappear_logs, userLogsDisappearInfos, userLogsIntegralInfos} from "@/api/admin/logs";

export default {
  name: "消证日志",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      modelOptions: [],
      userLogsInfosList:[],
      infoTotal:0,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 业务日志表格数据
      logsList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      infoQueryParams: {
        pageNum: 1,
        pageSize: 10,

        val: null,

      },
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        buiId: null,

        isType: null,

        modelName: null,

        jsonTxt: null,

        formInfo: null,

      },
      // 表单参数
      form: {},

    };
  },
  created() {
    this.getList();
    this.getDicts("logs_model").then((response) => {
      this.modelOptions = response.data;
    });
  },
  methods: {
    /** 查询业务日志列表 */
    getList() {
      this.loading = true;
      listDisappear_logs(this.queryParams).then(response => {
        this.logsList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getInfoList(){
        // 消证
        this.infoTitle = "用户消证详细记录"
        userLogsDisappearInfos(this.infoQueryParams).then(res =>{
          this.userLogsInfosList = res.rows;
          this.infoTotal = res.total;
        })

    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,

        buiId: null,

        isType: null,

        modelName: null,

        jsonTxt: null,

        formInfo: null,

        createBy: null,

        createTime: null,

        updateBy: null,

        updateTime: null,

      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    // 详细列表
    handleUpdate(row){
      this.infoQueryParams.buiId = row.userId;
        // 消证
        this.infoTitle = "用户消证详细记录"
        userLogsDisappearInfos(this.infoQueryParams).then(res =>{
          this.userLogsInfosList = res.rows;
          this.infoTotal = res.total;
        })
      this.open = true;

    }




  }
};
</script>
